package shiyan2;

public class Teacher {
	int Id;
    String Name;
    String sex;  
    Course[] cours;
    Teacher() {
        cours= new Course[3];
    }
    Teacher(int Id,String Name,String sex){
        this.Id = Id;
        this.Name = Name;
        this.sex = sex;  
        cours = new Course[3];
    }                                                  
    int getId() {
        return Id;
    }
    void setId(int Id) {
        this.Id = Id;
    }
    String getSex() {
		return sex;
	}
	void setSex(String sex) {
		this.sex = sex;
	}
	String getName() {
        return Name;
    }
    void setTeacherName(String Name) {
        this.Name = Name;
    }
    
    boolean Selected(Course course){
        boolean cnt=false;
        for(Course c:cours){
            if(c==course){
                cnt=true;
                break;
            }
        }
        return cnt;
    }
    
    boolean Null(Course course){
        boolean cnt=false;
        for(Course c:cours){
            if(c==null){
                cnt=true;
                break;
            }
        }
        return cnt;
    }
    
    boolean addCourse(Course course){
        boolean cnt=false;
        if(!Selected(course)&&Null(course)){
            for(int i=0;i<this.cours.length;i++){
                if(cours[i]==null){
                    cours[i]=course;
                    course.addTeacher(this);
                    cnt=true;
                    break;
                }
            }
        }
        return cnt;
    }
    
    void displayCourse(){
        System.out.println("教师：\n"+"ID："+this.Id+"\n姓名："+this.Name+this.sex);
        for(Course c:cours){
            if(c!=null){
                System.out.print("教授课程："+c.getName()+"\n");
            }
        }
        System.out.println();
    }


}
